package com.airy.highSpeed.controller;

import java.util.*;

import com.airy.highSpeed.entity.CktxCpcEntity;
import com.airy.highSpeed.service.CktxCpcService;
import com.airy.highSpeed.utils.PageUtils;
import com.airy.highSpeed.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ${comments}
 *
 * @author dingyakun
 * @email 821041490@qq.com
 * @date 2020-12-15 13:21:17
 */
@RestController
@RequestMapping("product/cktxcpc")
public class CktxCpcController {
    @Autowired
    private CktxCpcService cktxCpcService;

    /**
     * 查询所有
     */
    @RequestMapping("/findAll")
    public R findAll() {
        List<CktxCpcEntity> cpcEntityList = cktxCpcService.findAll();
        return R.ok().put("长度", cpcEntityList.size());
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = cktxCpcService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id) {
        CktxCpcEntity cktxCpc = cktxCpcService.getById(id);

        return R.ok().put("cktxCpc", cktxCpc);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CktxCpcEntity cktxCpc) {
        cktxCpcService.save(cktxCpc);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CktxCpcEntity cktxCpc) {
        cktxCpcService.updateById(cktxCpc);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids) {
        cktxCpcService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    //车流量
    public int findCountByStationNameAndBeginDateAndEndDate(Map<String, String> conditionMap) {
        return cktxCpcService.findCountByStationNameAndBeginDateAndEndDate(conditionMap);
    }

    public String findENSTATIONIDByStationName(String stationName) {
        return cktxCpcService.findENSTATIONIDByStationName(stationName);
    }

    public List<CktxCpcEntity> findAllLastweek(Map<String, String> mm) {
        return cktxCpcService.findAllLastweek(mm);
    }
}
